/// <reference path="SampleClass.ts" />
/// <reference path="Aspect.ts" />

(function () { // Start of scope (hide our function!)

    // This is just a function to write to the console when any of
    // our example events are called - you would write
    // something more specific

    var handler = (e: Aspect.WeaveEvent, a: any[]) => {
        var args = a.join(',');
        if (typeof console !== 'undefined') {
            console.log(e.toString() + ' Args: ' + args);
        }
    };

    // Example Working Method
    Aspect.Weaver.before(SampleClass, 'exampleMethod', handler);
    Aspect.Weaver.after(SampleClass, 'exampleMethod', handler);
    // Error not called because there are no errors
    Aspect.Weaver.error(SampleClass, 'exampleMethod', handler);
    Aspect.Weaver.afterAll(SampleClass, 'exampleMethod', handler);

    // Example Failing Method
    Aspect.Weaver.before(SampleClass, 'exampleFailingMethod', handler);
    // After not called because of error
    Aspect.Weaver.after(SampleClass, 'exampleFailingMethod', handler);
    Aspect.Weaver.error(SampleClass, 'exampleFailingMethod', handler);
    Aspect.Weaver.afterAll(SampleClass, 'exampleFailingMethod', handler);

} ()); // End of scope